<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>播放</title>
</head>
<body>
    <div id="video"></div>

    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <script>
        $(function(){
            var vid = getVidByUrl();
            loadVideo(vid);
        });

        //从url中获取vId
        function getVidByUrl(){
            let url = window.location.search; /* 获取完整URL */
            let vid = url.substring(url.lastIndexOf("=")+1);
            return vid;
        }

        //加载视频
        function loadVideo(vid){
            $("#video").empty();
            var html = '';
            $.post(("${pageContext.request.contextPath}/selectVideoByVid.do"),{vid:vid},function(result){
                if(result.status){
                    var obj = result.data;
                    html += '<h1><span>电影名:'+obj.vName+'<span>&nbsp;&nbsp;&nbsp;<span>导演:'+obj.director+'<span></h1>';
                    html += '<video src="'+obj.videoAddress+'" controls="controls" width="100%" height="80%"></video>';
                    $("#video").append(html);
                }else{
                    alert(result.message);
                }
            });
        }
    </script>
</body>
</html>
